package com.dragon.repository.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dragon.repository.entity.DoReminder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 待办提醒 Mapper 接口
 * </p>
 *
 * @author sy
 * @since 2023-06-27
 */
@Mapper
public interface DoReminderMapper extends BaseMapper<DoReminder> {


    @Select("<script>" +
            "select a.*, b.name as operationName, da.username as userName  from dragon_do_reminder a " +
            "left join dragon_dictsort_detail b on a.operation_type = b.`value` and b.code_type = 'noticeCode'  " +
            "left join dragon_admin da on a.from_id = da.id  " +
            " where  b.status = 0 and a.admin_id = #{adminId} " +
            "<if test='status!=null '>" +
            " and a.status = #{status} " +
            "</if> " +
            "order by a.create_time desc "+
            "</script>")
    Page<DoReminder> selectPageByAdminId(Page<DoReminder> page,Integer adminId,Integer status);


    @Select("select a.*,b.name operationName  from dragon_do_reminder a " +
            "left join dragon_dictsort_detail b on a.operation_type = b.`value` and b.code_type = 'noticeCode' " +
            " where  b.status = 0 and a.admin_id = #{adminId} ORDER BY a.create_time DESC ")
    Page<DoReminder> selectToDo (Page<DoReminder> page, Integer adminId);

    @Select("select distinct a.*  from dragon_do_reminder a " +
            "left join dragon_dictsort_detail b on a.operation_type = b.`value` and b.code_type != 'noticeCode' " +
            " where  b.status = 0 and a.admin_id = #{adminId} ORDER BY a.create_time DESC ")
    Page<DoReminder> selectMessage (Page<DoReminder> page, Integer adminId);
}
